<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>动画</title>

	<style type="text/css">
		.box{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
		}


	</style>
	<script type="text/javascript">

		function getStyle(obj, attr) 
		{ 
			if(obj.currentStyle){ 
				return obj.currentStyle[attr]; 
			}else{ 
				return getComputedStyle(obj,false)[attr]; 
			} 
		}

		window.onload = function  (argument) {
			var box = document.getElementById('box');
			var run = document.getElementById('run');
			var stop = document.getElementById('stop');


			var c = 1;
			var pao = function  () {
				width = parseInt(getStyle(box,'width'));
				height = parseInt(getStyle(box,'height'));

				if(width=='400'){
					c=0;
				}else if(width=='200'){
					c=1;
				}

				if(c){
					width +=5;
					height+=5;
				}else{
					width -=5;
					height-=5;
				}
				
				box.style.width=width+"px";
				box.style.height=height+"px";
			}

			time = 0;

			run.onclick = function  () {
				if(!time){
					time = setInterval(pao, 20);
				}
			}

			stop.onclick = function (){
				clearInterval(time);
				time=0;
			}



		}
	</script>
</head>
<body>

	<input type="button" value="动吧" id="run">
	<input type="button" value="停止" id="stop">

	<div class="box" id="box">
		
	</div>

	<script type="text/javascript">
		// var box = document.getElementById('box');

		// // alert(box.currentStyle['width']);

		// alert();


		 




	</script>
	
</body>
</html>